<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('特殊人员薪资查询')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<form id="form" class="form-horizontal" AUTOCOMPLETE="OFF">
    <div class="modal inmodal fade" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">特殊人员薪资查询</h4>
                </div>
                <div class="modal-body">
                    <p>
                        薪资套:<select id="pgid" name='pgid' class="form-control noselect2">
                    </select>
                    </p>

                    <p>
                        查询期间:
                        <input id="term" name="term" class="form-control datetimepicker" type="text">
                    </p>

                </div>
                <div class="modal-footer">
                    <button type="button" id="missmodal1" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button type="button" onclick="getInfo()" class="btn btn-primary">确认</button>
                </div>
            </div>
        </div>
    </div>
    <button type="button" id="modal1" class="btn btn-primary" data-toggle="modal"
            data-target="#myModal1">选择薪资套
    </button>

    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="user-form">
                        <div class="select-list">
                            <ul>
                                <li>
                                    工号：<input type="text" name="badge"/>
                                </li>
                                <li>
                                    姓名：<input type="text" name="name"/>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                            class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                            class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</form>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: hr-help-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>

<script th:inline="javascript">
    var prefix = ctx + "specialPersonSalaryQuery";
    var pgid;
    var term;

    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.datetimepicker',
                type: 'date'
            });
        });

        $("#modal1").attr("style", "display:none;");
        getSkypayGroups();
    });


    //获取数据集合
    function queryData() {
        var columns = [];
        var time = {field: 'term', title: '发薪时间', sortable: true};
        var badge = {field: 'badge', title: '工号', sortable: true};
        var name = {field: 'name', title: '姓名', sortable: true};
        var compName = {field: 'compName', title: '公司', sortable: true};
        var depName = {field: 'depName', title: '部门', sortable: true};
        var jobName = {field: 'jobName', title: '岗位', sortable: true};
        columns.push(time, badge, name, compName, depName, jobName);
        var other;
        $.ajax({
            async: false,
            url: ctx + "salaryCalculation/getPro",
            data: {"pgid": pgid},
            type: "post",
            dataType: "json",
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    other = {
                        field: data[i], title: data[i], sortable: true
                    }
                    columns.push(other);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

        var options = {
            url: prefix + "/list?pgid=" + pgid,
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            exportUrl: prefix + "/export?pgid=" + pgid,
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            pagination: false,
            showColumns: false,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            modalName: "基本信息",
            height: $(window).height() - 120,
            onLoadSuccess: function () {
                $(".th-inner").click(function () {
                    $(".fixed-table-loading").show();
                    setTimeout(function () {
                        $(".fixed-table-loading").hide();
                    }, 1000);
                });
            },
            columns: columns
        };
        $.table.init(options);
    }


    /**
     * 获取薪资套列表
     */
    function getSkypayGroups() {
        var html = "";
        $.ajax({
            async: false,
            url: ctx + "salaryCalculation/getSkypayGroups",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#pgid").empty();
                var arry = data;
                for (var i = 0; i < arry.length; i++) {
                    html += "<option value='"
                        + arry[i].id
                        + "'>"
                        + arry[i].title
                        + "</option>";
                }
                $("#pgid").append(html);
                $("#modal1").click();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {

                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    function getInfo() {
        pgid = $("#pgid").val();
        term = $("#term").val();
        $("#missmodal1").click();
        if (pgid != undefined && term != undefined) {
            queryData();
        }
    }
</script>
</body>
</html>